Do not emit action-activated signal when there are not actions selected
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sun, 30 Aug 2009 00:36:28 +0000 (20:36 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 30 Aug 2009 00:36:28 +0000 (20:36 -0400)
This was causing problems for epiphanys location entry, reported
in bug 593481.

gtk/gtkentry.c

index 7bf5c293966cb713fc6ce98b33fbe0c63d297d3f..866a88fa78491506cf204f1d61d97f248dba96e7 100644 (file)
@@ -9389,6 +9389,9 @@ keypress_completion_out:
            event->keyval == GDK_KP_Enter ||
           event->keyval == GDK_Return)
     {
+      GtkTreeIter iter;
+      GtkTreeModel *model = NULL;
+      GtkTreeSelection *sel;
       gboolean retval = TRUE;
 
       _gtk_entry_reset_im_context (GTK_ENTRY (widget));
@@ -9396,9 +9399,6 @@ keypress_completion_out:
 
       if (completion->priv->current_selected < matches)
         {
-          GtkTreeIter iter;
-          GtkTreeModel *model = NULL;
-          GtkTreeSelection *sel;
           gboolean entry_set;
 
           sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
@@ -9430,15 +9430,18 @@ keypress_completion_out:
         }
       else if (completion->priv->current_selected - matches >= 0)
         {
-          GtkTreePath *path;
-
-          _gtk_entry_reset_im_context (GTK_ENTRY (widget));
-
-          path = gtk_tree_path_new_from_indices (completion->priv->current_selected - matches, -1);
+          sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->action_view));
+          if (gtk_tree_selection_get_selected (sel, &model, &iter))
+            {
+              GtkTreePath *path;
 
-          g_signal_emit_by_name (completion, "action-activated",
-                                 gtk_tree_path_get_indices (path)[0]);
-          gtk_tree_path_free (path);
+              path = gtk_tree_path_new_from_indices (completion->priv->current_selected - matches, -1);
+              g_signal_emit_by_name (completion, "action-activated",
+                                     gtk_tree_path_get_indices (path)[0]);
+              gtk_tree_path_free (path);
+            }
+          else
+            retval = FALSE;
         }
 
       g_free (completion->priv->completion_prefix);